package com.example.mybatisplus.controller;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.mybatisplus.entity.User;
import com.example.mybatisplus.mapper.UserMapper;
import com.example.mybatisplus.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {

    @Autowired
    private IUserService userService;

    @Autowired
    private UserMapper userMapper;

    @DS(value = "master")
    @GetMapping(value = "/listUser")
    public List<User> listUser() {
        List<User> list = userService.list();
        return list;
    }

    @DS(value = "slave")
    @GetMapping(value = "listUser2")
    public List<User> listUser2() {
        List<User> list = userService.list();
        return list;
    }

    @GetMapping(value = "/test")
    public List<User> test() {
        List<User> users = userMapper.selectAll(1L);
        return users;
    }
}


